<?php
	include($_SERVER['DOCUMENT_ROOT']."/wewant1/includes/img_process/crop_image.php");
	include($_SERVER['DOCUMENT_ROOT']."/wewant1/includes/db_exe/db_connection.php");
?>
<?php
	if($_SERVER['REQUEST_METHOD']=='POST'){
		if(isset($_FILES['image'])){
			//lay ra type cua file anh
			$extType = end(explode('.', $_FILES['image']['tmp_name']));
			//dat lai ten cho file image random va dung luu vao database
			$dstName = uniqid(rand(),true);	
			
			//gan lai file name tmp cho source dung de xu ly ham crop sau nay
			$imgScr = $_FILES['image']['tmp_name'];

			//tien hanh crop va chuyen du lieu vao trong folder upload, chuyen 3 file x354, x200, original
			cropImage($imgScr,354,$dstName);
			cropImage($imgScr,200,$dstName);
			
			//chuyen file original khong crop voi cung dstName
			move_uploaded_file($_FILES['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/wewant1/upload/image_product/'.$dstName.'.jpg');

		}
	}
?>